﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace WindowsFormsApplication2.Model
{
    class Free_Gift
    {

        int id;
        int id_layanan_cabang;
        string nama;
        int kuantitas;
        bool tidak_aktif;

        public Free_Gift()
        {

        }

        public Free_Gift(string _Nama)
        {
            Database db = new Database();
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            string sql = "SELECT * FROM free_gift WHERE nama = '" + _Nama + "'";

            db.Open();
            ds = db.ExecuteQuery(sql);
            dt = ds.Tables[0];
            DataRow dr = dt.Rows[0];

            id = (int)dr[0];
            id_layanan_cabang = (int)dr[1];
            nama = (string)dr[2];
            kuantitas = (int)dr[3];
            tidak_aktif = (bool)dr[4];

            db.Close();
        }

        public ArrayList daftarStokCabang(int _stoc_saja)
        {
            return null;
        }

        public void addCabang()
        {
            Database db = new Database();
            string sql = "INSERT INTO free_gift(id_layanan_cabang, nama, kuantitas, tidak_aktif) VALUES ('" + id_layanan_cabang.ToString() + "','" + nama + "','" + kuantitas.ToString() + "','" + tidak_aktif.ToString() + "')";
            db.Open();
            db.ExecuteNonQuery(sql);
            db.Close();

        }

        public void updateFree_Gift()
        {
        }

        public void deleteFree_Gift()
        {
        }

    }
}
